package cn.stylefeng.guns.modular.hx.storage.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.hx.storage.entity.HxStorageOutDetailed;
import cn.stylefeng.guns.modular.hx.storage.mapper.HxStorageOutDetailedMapper;
import cn.stylefeng.guns.modular.hx.storage.model.params.HxStorageOutDetailedParam;
import cn.stylefeng.guns.modular.hx.storage.model.result.HxStorageOutDetailedResult;
import  cn.stylefeng.guns.modular.hx.storage.service.HxStorageOutDetailedService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 拣货单明细表 服务实现类
 * </p>
 *
 * @author zhucx
 * @since 2023-09-05
 */
@Service
public class HxStorageOutDetailedServiceImpl extends ServiceImpl<HxStorageOutDetailedMapper, HxStorageOutDetailed> implements HxStorageOutDetailedService {

    @Override
    public void add(HxStorageOutDetailedParam param){
        HxStorageOutDetailed entity = getEntity(param);
        this.save(entity);
    }

    @Override
    public void delete(HxStorageOutDetailedParam param){
        this.removeById(getKey(param));
    }

    @Override
    public void update(HxStorageOutDetailedParam param){
        HxStorageOutDetailed oldEntity = getOldEntity(param);
        HxStorageOutDetailed newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }

    @Override
    public HxStorageOutDetailedResult findBySpec(HxStorageOutDetailedParam param){
        return this.baseMapper.findBySpec(param);
    }

    @Override
    public List<HxStorageOutDetailedResult> findListBySpec(HxStorageOutDetailedParam param){
        return this.baseMapper.findListBySpec(param);
    }

    @Override
    public LayuiPageInfo findPageBySpec(HxStorageOutDetailedParam param,String condition){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageList(pageContext, param,condition);
        return LayuiPageFactory.createPageInfo(page);
    }

    @Override
    public LayuiPageInfo findjiluPageBySpec(HxStorageOutDetailedParam param,String condition){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.findjiluPageBySpec(pageContext, param,condition);
        return LayuiPageFactory.createPageInfo(page);
    }

    private Serializable getKey(HxStorageOutDetailedParam param){
        return param.getId();
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }

    private HxStorageOutDetailed getOldEntity(HxStorageOutDetailedParam param) {
        return this.getById(getKey(param));
    }

    private HxStorageOutDetailed getEntity(HxStorageOutDetailedParam param) {
        HxStorageOutDetailed entity = new HxStorageOutDetailed();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }

	@Override
	public HxStorageOutDetailedResult findZySumBySpec(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
		return this.baseMapper.findZySumBySpec(hxStorageOutDetailedParam);
	}

    @Override
    public HxStorageOutDetailedResult findJhZSumBySpec(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
        return this.baseMapper.findJhZSumBySpec(hxStorageOutDetailedParam);
    }

    @Override
    public List<HxStorageOutDetailedResult> findZySumList(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
        return this.baseMapper.findZySumList(hxStorageOutDetailedParam);
    }

	@Override
	public boolean saveBatchList(List<HxStorageOutDetailedParam> list) {
		return this.baseMapper.saveBatchList(list);
	}

    @Override
    public int addByStorageNumber(String storageNumber,String newStorageNumber) {
        return this.baseMapper.addByStorageNumber(storageNumber,newStorageNumber);
    }

    @Override
    public List<HxStorageOutDetailedResult> selectGoodSNumByStorageNumber(String storageNumber) {
        return this.baseMapper.selectGoodSNumByStorageNumber(storageNumber);
    }

    @Override
	public List<HxStorageOutDetailedResult> findApplistBySpec(HxStorageOutDetailedParam param) {
		return this.baseMapper.findApplistBySpec(param);
	}

    @Override
    public List<HxStorageOutDetailedResult> findAppzhijianDetailedlistBySpec(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
        return this.baseMapper.findAppzhijianDetailedlistBySpec(hxStorageOutDetailedParam);
    }

    @Override
    public List<HxStorageOutDetailedResult> findAppzhijianCountDetailedlistBySpec(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
        return this.baseMapper.findAppzhijianCountDetailedlistBySpec(hxStorageOutDetailedParam);
    }


    /**
     * 查询打印明细
     * @param
     * @return
     */
    @Override
    public List<HxStorageOutDetailedResult> findListBySpec2(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
        return this.baseMapper.findListBySpec2(hxStorageOutDetailedParam);
    }
    /**
     * 出库质检扫码枪
     * @param
     * @return
     */
    @Override
    public void update1(HxStorageOutDetailedParam param) {
         this.baseMapper.update1(param);
    }

	@Override
	public void updatequalityNumBySpec(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
		this.baseMapper.updatequalityNumBySpec(hxStorageOutDetailedParam);
	}

	@Override
	public void updaterealNumBySpec(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
		this.baseMapper.updaterealNumBySpec(hxStorageOutDetailedParam);
	}

	@Override
	public boolean updateBatchList(List<HxStorageOutDetailedParam> _list2) {
		return this.baseMapper.updateBatchList(_list2);
	}

	@Override
	public boolean updateBatchList2(List<HxStorageOutDetailedParam> _list2) {
		return this.baseMapper.updateBatchList2(_list2);
	}

	@Override
	public List<HxStorageOutDetailedResult> findNumNotRealNumListBySpec(HxStorageOutDetailedParam detailedParam) {
		return this.baseMapper.findNumNotRealNumListBySpec(detailedParam);
	}

	@Override
	public HxStorageOutDetailedResult findnewestoutDetailed(HxStorageOutDetailedParam hxStorageOutDetailedParam) {
		return this.baseMapper.findnewestoutDetailed(hxStorageOutDetailedParam);
	}

	@Override
	public HxStorageOutDetailedResult count(HxStorageOutDetailedParam hxStorageOutDetailedParam, String condition) {
		return this.baseMapper.count(hxStorageOutDetailedParam,condition);
	}

	@Override
	public List<HxStorageOutDetailedResult> listAll(HxStorageOutDetailedParam hxStorageOutDetailedParam,
			String condition) {
		return this.baseMapper.listAll(hxStorageOutDetailedParam,condition);
	}

    @Override
    public int updateCode(HxStorageOutDetailedParam param) {
        return this.baseMapper.updateCode(param);
    }

    @Override
    public int updateOrder(HxStorageOutDetailedParam param) {
        return this.baseMapper.updateOrder(param);
    }
}
